package com.hks360.car_treasure.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.List;

/**
 * Created by xiaote on 2016/3/17.
 */
public class FragmentAdapter extends FragmentPagerAdapter {
    private static final String[] TITLE = new String[] { "登录", "注册" };
    private List<Fragment> fragments;

    public FragmentAdapter(FragmentManager fm,List<Fragment> fragments) {
        super(fm);
        this.fragments = fragments;
    }

    public FragmentAdapter(FragmentManager fm) {
        super(fm);
    }
    @Override
    public Fragment getItem(int position) {
        return fragments == null ? null : fragments.get(position);
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return TITLE[position % TITLE.length];
    }
    @Override
    public int getCount() {
       return fragments == null ? 0 : fragments.size();
    }
}
